begintownscript;
variables;
int = i,j;
short water,choice;
body;

beginstate init_state;
water = 0;
set_flag(2,20,1);
set_name(23,"Huge rat");
set_level(23,30);

add_char_to_group(21,1);
add_char_to_group(22,1);
add_char_to_group(6,1);
add_char_to_group(19,1);
add_char_to_group(13,1);
add_char_to_group(17,1);
add_char_to_group(15,1);
add_char_to_group(18,1);
add_char_to_group(14,1);
add_char_to_group(16,1);
add_char_to_group(23,1);

if(get_flag(2,0) == 1) 
		{
		set_terrain(20,33,137);
		set_terrain(19,33,137);
		set_height(20,33,5);
		set_height(19,33,5);
		set_floor(19,33,24);
		set_floor(20,33,24);
		set_terrain(34,13,0);
		set_terrain(34,11,0);
		set_terrain(33,9,0);
		set_terrain(30,8,0);
		set_terrain(30,7,0);
		set_terrain(34,7,0);
		set_terrain(35,7,0);
		set_terrain(32,6,0);
		set_terrain(33,6,0);
		set_terrain(34,6,0);
		set_terrain(35,5,0);
		set_terrain(34,4,0);
		set_terrain(32,4,0);
		set_terrain(31,4,0);
		set_terrain(30,4,0);
		set_terrain(33,3,0);
		set_terrain(32,3,0);
		set_terrain(31,3,0); }

if(get_flag(2,8) == 1) {
	swap_floor(23,45,131,4);
	swap_floor(24,45,131,4);
	swap_floor(23,46,58,4);
	swap_floor(24,46,58,4);
	swap_floor(23,47,58,4);
	swap_floor(24,47,58,4);
	swap_floor(21,48,58,4);
	swap_floor(22,48,58,4);
	swap_floor(23,48,58,4);
	swap_floor(24,48,58,4);
	swap_floor(25,48,58,4);
	swap_floor(26,48,58,4);
	swap_floor(21,49,58,4);
	swap_floor(22,49,58,4);
	swap_floor(23,49,58,4);
	swap_floor(24,49,58,4);
	swap_floor(25,49,58,4);
	swap_floor(26,49,58,4);
	swap_floor(21,50,58,4);
	swap_floor(22,50,58,4);
	swap_floor(23,50,58,4);
	swap_floor(24,50,58,4);
	swap_floor(25,50,58,4);
	swap_floor(26,50,58,4);
}
if (get_flag(2,5) == 1) {
	set_terrain(36,39,138);
	set_terrain(35,39,21); }
break;


beginstate exit_state;
break;

beginstate start_state;
j = 0;
while(j <=4)
{	if(char_ok(j) == 1)
		while(get_char_status(j,6) > 6)
		{	set_char_status(j,6,-1,1,0); }
	j = j + 1; }

if(num_chars_in_group(1) == 0)
{	set_flag(2,20,0);
	if(get_flag(2,21) == 0)
	{	message_dialog("The last dire rat falls dead. The swarm of rats ceases. You can check out their nest now.","");
		set_flag(2,21,1); }
}

if(get_flag(2,24) > 0)
{	water = water + 1;
	if(water == 60)
		message_dialog("The rising water level is beginning to make you uneasy. If you wait much longer the walkways you are using will be flooded, and any chance of escape will be gone.","");
	if(water == 125)
		message_dialog("The water is splashing at your feet, you're going to have to find a way to release the water","");
	if(water == 185)
	{	message_dialog("The rushing water has risen too high. It has flooded all of the dry ground, and swept you away. You are quickly dragged down by the swirling eddies and drown, how unfortunate.","");
		i = 0;
		while(i <= 5)
		{	kill_char(i,2,0);
			i = i + 1; }
}
}

break;

beginstate 10;
	teleport_party(10,50,1);
break;

beginstate 11;
if (is_combat())
	{message_dialog("Theres no way you could get across this pit with your weapons in hand. Put them away so you can work with both hands.","");
	block_entry(1);
	end();
}

	if (has_item(391) == 0) {
		message_dialog("The floor in this room has collapsed. It is to far to jump, and you have nothing to help you cross. You have to turn back, but perhaps if you had a rope or cord you would have a chance.",""); }
	else {
	reset_dialog();	
	add_dialog_str(0,"The floor in this room has collapsed. You spy a hook-shaped rock outcropping on the ceiling by the west side of the pit, and take out your rope. You could probably throw the rope over and swing across, do you?",0);
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Attempt to swing across.");
	choice = run_dialog(1);
	if (choice == 1)
		end();
	if (choice == 2)
		{ block_entry(1);
		march_party(53,35);
		force_instant_terrain_redraw();
			i = 0;
	while (char_ok(i) == 0)
		{i = i + 1; }
	force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);

		march_party(52,35);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);

		march_party(51,35);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);

		march_party(50,35);
		force_instant_terrain_redraw();	
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);

		march_party(49,35);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);

		march_party(48,35);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);

		march_party(47,35);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);

		march_party(47,34);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);


		message_dialog("You make it across safely and wind up your rope. You should be able to make it back in the same manner.","");
}
}
break;

beginstate 12;
if (is_combat())
	{message_dialog("Theres no way you could get across this pit with your weapons in hand. Put them away so you can work with both hands.","");
	block_entry(1);
	end();
}
	if (has_item(391) == 0) {
	("The floor in this room has collapsed. It is to far to jump, and you have nothing to help you cross. You have to turn back.",""); }
	else { reset_dialog();
	add_dialog_str(0,"You return to the room with the collapsed floor. You didn't have any problems swinging across earlier, should you try again?",0); 
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Attempt to swing across.");
	choice = run_dialog(1);
	if (choice == 1)
		end();
	if (choice == 2)
		{block_entry(1);
		i = 0;
		while(char_ok(i) == 0)
		{ i = i + 1; }
		march_party(50,35);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);
		
		march_party(51,35);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);

		march_party(52,35);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);

		march_party(53,35);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);

		march_party(54,35);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);

		march_party(55,35);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);

		march_party(56,35);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);

		march_party(57,35);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(3);

	message_dialog("Soon as you set foot on solid ground you wrap up your rope. You are starting to hate whoever built such a shoddy floor.",""); }
break;

beginstate 13;
	reset_dialog();
	add_dialog_str(0,"The water level is rising quickly. The water below these falls has gotten high enough that the dangerous rocks below are now underwater.",0);
	add_dialog_str(1,"However, just because you can't see these rocks anymore doesn't mean they can't still wreck your boat. Should you try to go over the falls?",0); 
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Row over the falls.");
	choice = run_dialog(1);
	if (choice == 1)
		end();
	if (choice == 2)
		{block_entry(1);

		march_party(20,19);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(5);

		march_party(21,19);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		play_sound(100);
		pause(5);

		march_party(22,19);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(5);

		march_party(23,19);
		force_instant_terrain_redraw();
		force_view_center(char_loc_x(i),char_loc_y(i));
		pause(5);
message_dialog("You survive the waterfall. Now you just have to let out all this water before it floods the whole sewers.",""); }
break;

beginstate 14;
	if (has_special_item(1) == 0) {
	message_dialog("You look down at this control panel and have no idea what to do. There are lots of buttons, and none have labels. You wisely decide not to try to use them until you know what you are doing.","");
	end();
	}
	else {
	reset_dialog();
	add_dialog_str(0,"You look down at this control panel and have no idea what to do. There are lots of buttons, and none have labels.",0);
	add_dialog_str(1,"Fortunately the instructions you found in the library seem to correspond with the buttons on this control panel, you should be able to use it; now you have to hope it still works.",0); 
	add_dialog_choice(0,"Leave it alone.");
	add_dialog_choice(1,"Open water control gates.");
	add_dialog_choice(2,"Close water  control gates.");
	choice = run_dialog(1);
	if (choice == 1) {
		end(); }
	if (choice == 2) { 
		if(get_flag(2,1) == 0) {
		message_dialog("Nothing happens. A yellow light flashes, a quick look at your instruction manual tells you this means the gates are already open.","");
		end(); }
		else {
		message_dialog("You try to open the gates back up and release the built up water. A red light flashes on the control panel. Your manual tells you this means the machinery is critically damaged, you'll have to open up the main drainage channel.","");
		end(); }
}
	if (choice == 3) {
		if(get_flag(2,1) == 1) {
		message_dialog("Nothing happens. A yellow light flashes, a quick look at your instruction manual tells you this means the gates are already closed.",""); }
		else {
		set_flag(2,1,1);	
		message_dialog("You hear rusted machinery slowly start to turn, grinding and clanking echoes throughout the sewers. You stand by the control panel looking out at the sewers for several minutes to see if it worked.","");
		play_sound(99);
	message_dialog("It definately worked, the water level is rising alarmingly quickly. You need to hurry and do something about this.","");
		set_terrain(44,20,0);
		set_terrain(45,20,0);
		set_terrain(44,21,0);
		set_terrain(45,21,0);
		set_terrain(44,22,0);
		set_terrain(45,22,0);
		set_terrain(22,19,0);
		set_terrain(22,20,0);
		set_flag(2,24,1);

		swap_floor(40,21,7,23);
		swap_floor(40,22,7,23);
		swap_floor(40,23,7,23);
		swap_floor(40,24,7,23);
		set_terrain(40,24,0);

		swap_floor(44,35,123,23);
		swap_floor(44,36,123,23);
		swap_floor(44,37,123,23);
		swap_floor(44,38,123,23);
		swap_floor(44,39,123,23);
		swap_floor(45,38,123,23);
		swap_floor(45,39,123,23);
		swap_floor(46,38,123,23);
		swap_floor(46,39,123,23);
		swap_floor(47,38,123,23);
		swap_floor(47,39,123,23);
		swap_floor(48,38,123,23);
		swap_floor(48,39,123,23);
		swap_floor(47,40,123,31);
		swap_floor(48,40,123,31);

		swap_floor(21,30,123,23);
		swap_floor(21,29,123,23);
		swap_floor(21,28,123,23);
		swap_terrain(21,30,0,301);
		swap_terrain(21,29,0,301);
		swap_terrain(21,28,0,301);

		swap_floor(18,31,123,23);
		swap_floor(18,30,123,23);
		swap_floor(18,29,123,23);
		swap_terrain(18,30,0,301);
		swap_terrain(18,29,0,301);
		end();	}
}
break;

beginstate 15;
if (has_special_item(1) == 0) {
	message_dialog("This control panel is very beat up. You doubt if it would work, and don't know how to operate it if it would.","");
	end(); }
	else {
	reset_dialog();
	add_dialog_str(0,"This control panel looks to be in very bad shape.",0);
	add_dialog_str(1,"You don't know how to work it, but your instruction manual from the library should help you out.",0); 
	add_dialog_choice(0,"Leave it alone.");
	add_dialog_choice(1,"Close main drainage channel.");
	add_dialog_choice(2,"Open main drainage channel.");
	choice = run_dialog(1);
	if (choice == 1) {
		end(); }
	if (choice == 2) {
		message_dialog("Nothing happens. A yellow light flashes, a quick look at your instruction manual tells you this means the gates are already closed.","");
		end(); }
	if (choice == 3) {
		message_dialog("You hear a great clanging and rattling as chains pull long dormant machinery into motion. However, it soon comes to a screeching halt. It seems that the machinery is too old, and there is to much debris clogging the gates.","");
		play_sound(99);
		if(get_flag(2,1) == 1) {
		message_dialog("The main drainage channel leading to Lake Tybor lies to the north. It is the only way to let out water from the sewers, except for the water control gates. If it is jammed, you will have to find another way to open it.",""); }
		end(); }
}
break;
beginstate 16;
		if(get_flag(2,1) == 0) {
		message_dialog("The water below these falls looks pretty shallow, you can see large rocks just below you. It would be a very bad idea to row any further.","");
		block_entry(1);		}
break;

beginstate 17;
		if(get_flag(2,3) == 0) {
		message_dialog("You dig through this old desk, and find a handwritten booklet of papers detailing the complex orders required to operate the sewer's machinery. It must have been left behind by some operator who didn't want to forget how to do his job.","");
		change_spec_item(1,1);
		set_flag(2,3,1); }
break;
beginstate 18;
		if(get_flag(2,4) == 0) {
		message_dialog("The stench in this room causes you to nearly choke. Nonetheless you poke through the piles of filth on the floor. You are rewarded for your suffering when you find a key strung on a chain around a dead body's neck.","");
		change_spec_item(2,1);
		set_flag(2,4,1); }
break;

beginstate 19;
		if(get_flag(2,1) > 0) {
		message_dialog("The current here is to fast, if you proceed you will be not be able to control your boat. You wisely turn back.","");
		block_entry(1); }
break;
beginstate 20;
		if(get_flag(2,5) == 0){
		reset_dialog();
		add_dialog_str(0,"The metal latch and lock on the box's lid are covered in corrosion. They are in to bad a shape to pick them, you will have to try something else to open it.",0);
		add_dialog_str(1,"The wood of the box looks weak. You could hack through it with your weapons.",0);
		add_dialog_choice(0,"Leave it alone.");
		add_dialog_choice(1,"Smash it.");
		choice = run_dialog(1);
		if (choice == 1) {
			end(); }
		if (choice == 2) {
			message_dialog("You draw your weapons and smash the lid to splinters. You eagerly rummage through the filthy contents of the box, but are disappointed when you only find a small flask devoid of labels.","");
		play_sound(107);
		char_give_item(0,450);
		set_flag(2,5,1);
		set_terrain(36,39,138);
		message_dialog("All the noise from you hacking at the box seems to have desturbed the residents of this room, hissing pools of acid begin to poor from the walls.","");
		activate_hidden_group(1); }
}
break;
beginstate 21;
		message_dialog("This is the source that feeds the sewers. You hear water crashing somewhere down the river, going any further will only risk getting smashed by a waterfall.","");
		block_entry(1);
break;
beginstate 22;
	if(get_flag(2,0) == 0);
	reset_dialog();
	add_dialog_str(0,"This wheel will hopefully open the main drainage channel.",0);
	add_dialog_choice(0,"Leave it alone.");
	add_dialog_choice(1,"Turn it.");
	choice = run_dialog(1);
	if (choice == 1) {
		end(); }
	if (choice == 2) {
		message_dialog("You turn the wheel and hope for the best. If it doesn't open the flood gates below, you will very likely be trapped here by the rising water.","");
		play_sound(99);
		message_dialog("You watch the gates below you in anticipation, you heave a sigh of relief when they open. A great rush of water explodes out the gates.","");
		
		play_sound(100);
		force_view_center(31,7);
		set_total_visibility(1);
		flip_terrain(32,5);
		flip_terrain(31,5);
		text_bubble_on_char(8,"*clang*");
		force_instant_terrain_redraw();
		pause(4);

		move_item_on_spot(32,6,-1,0);
		move_item_on_spot(31,6,-1,0);
		set_terrain(31,5,32);
		set_terrain(32,5,32);
		set_terrain(31,4,223);
		set_terrain(32,4,223);
		set_terrain(31,16,432);
		set_terrain(32,16,432);

		force_instant_terrain_redraw();
		pause(4);

		text_bubble_on_char(8,"");
		set_terrain(31,15,432);
		set_terrain(32,15,432);
		set_terrain(31,16,0);
		set_terrain(32,16,0);		
		set_terrain(31,4,0);
		set_terrain(32,4,0);
		set_terrain(31,3,223);
		set_terrain(32,3,223);
		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,15,0);
		set_terrain(32,15,0);
		set_terrain(31,14,432);
		set_terrain(32,14,432);
		set_terrain(31,3,0);
		set_terrain(32,3,0);	
		set_terrain(31,2,223);
		set_terrain(32,2,223);
		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,14,0);
		set_terrain(32,14,0);
		set_terrain(31,13,432);
		set_terrain(32,13,432);
		set_terrain(31,2,0);
		set_terrain(32,2,0);
		set_terrain(31,1,223);
		set_terrain(32,1,223);
		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,1,0);
		set_terrain(32,1,0);
		set_terrain(31,13,0);
		set_terrain(32,13,0);
		set_terrain(31,12,432);
		set_terrain(32,12,432);
		set_terrain(34,13,0);
		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,12,0);
		set_terrain(32,12,0);
		set_terrain(31,11,432);
		set_terrain(32,11,432);
		set_terrain(34,11,0);
		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,11,0);
		set_terrain(32,11,0);
		set_terrain(31,10,432);
		set_terrain(32,10,432);
		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,10,0);
		set_terrain(32,10,0);
		set_terrain(31,9,432);
		set_terrain(32,9,432);
		set_terrain(33,9,0);
		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,9,0);
		set_terrain(32,9,0);
		set_terrain(31,8,432);
		set_terrain(32,8,432);
		set_terrain(30,8,0);
		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,8,0);
		set_terrain(32,8,0);
		set_terrain(31,7,432);
		set_terrain(32,7,432);
		set_terrain(30,7,0);
		set_terrain(34,7,0);
		set_terrain(35,7,0);

		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,7,0);
		set_terrain(32,7,0);
		set_terrain(31,6,432);
		set_terrain(32,6,432);
		set_terrain(32,6,0);
		set_terrain(33,6,0);
		set_terrain(34,6,0);
		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,6,0);
		set_terrain(32,6,0);
		set_terrain(31,5,432);
		set_terrain(32,5,432);
		set_terrain(35,5,0);
		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,5,32);
		set_terrain(32,5,32);
		set_terrain(31,4,432);
		set_terrain(32,4,432);
		set_terrain(34,4,0);
		set_terrain(32,4,0);
		set_terrain(31,4,0);
		set_terrain(30,4,0);
		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,4,0);
		set_terrain(32,4,0);
		set_terrain(31,3,432);
		set_terrain(32,3,432);
		set_terrain(33,3,0);
		set_terrain(32,3,0);
		set_terrain(31,3,0);
		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,3,0);
		set_terrain(32,3,0);
		set_terrain(31,2,432);
		set_terrain(32,2,432);
		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,2,0);
		set_terrain(32,2,0);
		set_terrain(31,1,432);
		set_terrain(32,1,432);
		force_instant_terrain_redraw();
		pause(4);

		set_terrain(31,1,0);
		set_terrain(32,1,0);
		set_terrain(31,0,432);
		set_terrain(32,0,432);
		force_instant_terrain_redraw();
		pause(4);
		
		set_terrain(31,0,0);
		set_terrain(32,0,0);
		force_instant_terrain_redraw();
		pause(4);

		message_dialog("The wave roars past you and rushes north, washing away the filth that previously clogged this channel, your work here is done.","");
		set_total_visibility(0);
			i = 0;
	while (char_ok(i) == 0)
		{i = i + 1; }
	force_view_center(char_loc_x(i),char_loc_y(i));
		play_sound(26);

		set_terrain(44,20,125);
		set_terrain(45,20,126);
		set_terrain(44,21,126);
		set_terrain(45,21,127);
		set_terrain(44,22,127);
		set_terrain(45,22,125);
		set_terrain(20,33,137);
		set_terrain(19,33,137);

		swap_floor(40,21,4,23);
		swap_floor(40,22,4,23);
		swap_floor(40,23,4,23);
		swap_floor(40,24,4,23);
		set_terrain(40,24,0);

		swap_floor(44,35,123,23);
		swap_floor(44,36,123,23);
		swap_floor(44,37,123,23);
		swap_floor(44,38,123,23);
		swap_floor(44,39,123,23);
		swap_floor(45,38,123,23);
		swap_floor(45,39,123,23);
		swap_floor(46,38,123,23);
		swap_floor(46,39,123,23);
		swap_floor(47,38,123,23);
		swap_floor(47,39,123,23);
		swap_floor(48,38,123,23);
		swap_floor(48,39,123,23);
		swap_floor(47,40,123,31);
		swap_floor(48,40,123,31);

		swap_floor(21,30,123,23);
		swap_floor(21,29,123,23);
		swap_floor(21,28,123,23);
		swap_terrain(21,30,0,301);
		swap_terrain(21,29,0,301);
		swap_terrain(21,28,0,301);
		swap_terrain(47,39,0,223);

		swap_floor(18,31,123,23);
		swap_floor(28,30,123,23);
		swap_floor(28,29,123,23);
		swap_terrain(18,30,0,301);
		swap_terrain(18,29,0,301);

		set_height(20,33,5);
		set_height(19,33,5);
		set_floor(19,33,24);
		set_floor(20,33,24);
		set_flag(2,0,1);
		set_flag(2,24,0);
end(); }
break;

beginstate 23;
	if(get_flag(2,0) == 1) {
		message_dialog("The water level is back to regular; the rocks that once blocked this channel are now exposed again. You can't get out this way.","");	
	block_entry(1); }
break;

beginstate 24;
	reset_dialog();
	add_dialog_str(0,"Ascend to the surface.",0);
	add_dialog_choice(0,"Turn back.");
	add_dialog_choice(1,"Climb stairs.");
	choice = run_dialog(1);
	if (choice == 1) {
		end(); }
	if (choice == 2) { 
	message_dialog("This stairway must have been an emergency escape route. You walk through a twisty corridor, ever slanting up towards the surface, for what seems like hours. You finally reach the exit.","");
	move_to_new_town(0,19,4); }
break;

beginstate 25;
	if(get_flag(2,0) == 1) {
	message_dialog("The bridge here was washed out in the surge when you opened the main channel. You won't be able to get to the rest of the sewers.",""); }
break;

beginstate 26;
	if(get_flag(2,6) == 0) {
	message_dialog("The smell here is horrible. The stench of decaying matter and the sound of rushing water both tell you one thing. You've found the sewers of Mountainwatch.","");
	set_flag(2,6,1); }
break;

beginstate 27;
	if(get_flag(2,7) == 0) {
	message_dialog("An old boat is tied to a post on these docks. Its boards are warped, and a small pool of water has gathered in the bottom of its hull, but it looks like it will float.","You can now navigate the waters of the sewers, as long as you're willing to risk sinking in a river of filth.");
	set_flag(2,7,1); }
break;

beginstate 28;
	if(get_flag(2,8) == 0) {
	message_dialog("Putrid water flows from the room to the south. You can see water pooring into this room from a hole in the ceiling, but since the room is slightly higher in elevation than you are, you can't investigate closer.","");
}
	else
	message_dialog("The wheel you turned has stopped the flow of water into this room. The water here must have been pretty shallow, because you can see the floor. It is covered in trash and debris. It reeks.","");
break;
beginstate 29;
	if(get_flag(2,9) == 0) {
	message_dialog("The river passes underneath a stone walkway ahead. You won't be able to go any further.","");
	set_flag(2,9,1); }
break;

beginstate 30;
	if(get_flag(2,10) == 0) {
	message_dialog("The rats in this room are not mere sewer rats, they are far larger than any normal rat you have ever seen before. You have the misfortune to stumble upon the room where they have chosen to make their nest.","You see a glint of metal from the rat nest, you'll have to check it out once all the rats are dead.");
	set_flag(2,10,1); }
break;

beginstate 31;
	if(get_flag(2,11) == 0) {
	message_dialog("You can hear squeaking and scurrying coming from behind this door. This would probably mean rats, and the scurrying sounds like awfully big paws.","");
	set_flag(2,11,1); }
break;

beginstate 32;
	if(get_flag(2,12) == 0) {
	message_dialog("You look out over the sewers, and see a disturbing sight.","");
		
		set_total_visibility(1);
		force_view_center(31,22);
		force_instant_terrain_redraw();
		pause(3);	

		force_view_center(31,21);
		force_instant_terrain_redraw();
		pause(3);

		force_view_center(31,20);
		force_instant_terrain_redraw();
		pause(3);

		force_view_center(31,19);
		force_instant_terrain_redraw();
		pause(3);

		force_view_center(31,18);
		force_instant_terrain_redraw();
		pause(3);

		force_view_center(31,17);
		force_instant_terrain_redraw();
		pause(3);

		force_view_center(31,16);
		force_instant_terrain_redraw();	
		pause(3);

		force_view_center(31,15);
		force_instant_terrain_redraw();
		pause(3);

		force_view_center(31,14);
		force_instant_terrain_redraw();	
		pause(3);

		force_view_center(31,13);
		force_instant_terrain_redraw();
		pause(3);

		force_view_center(31,12);
		force_instant_terrain_redraw();
		pause(3);

		force_view_center(31,11);
		force_instant_terrain_redraw();
		pause(3);

		force_view_center(31,10);
		force_instant_terrain_redraw();
		pause(3);

		force_view_center(31,9);
		force_instant_terrain_redraw();
		pause(3);

		force_view_center(31,8);
		force_instant_terrain_redraw();
		pause(3);

		force_view_center(31,7);
		force_instant_terrain_redraw();
		pause(3);

		force_view_center(31,6);
		force_instant_terrain_redraw();
		pause(15);

		message_dialog("The gates blocking this channel are closed, and debris and filth have piled up around them. Water flow has been reduced to a trickle through this drain.","");

		set_total_visibility(0);
			i = 0;
	while (char_ok(i) == 0)
		{i = i + 1; }
	force_view_center(char_loc_x(i),char_loc_y(i));
		force_instant_terrain_redraw();
		message_dialog("This would explain the filth buildup throughout the sewers. It looks like the path to Mountainwatch itself is through the blocked passage to the north. You'll have to clear the way if you want to achieve your goal.","");
		set_town_visibility(6,1);
		set_flag(2,12,1); }
break;

beginstate 33;
		if(get_flag(2,13) == 0) {
		message_dialog("You see what was once a dock to the north of you. Unfortunately the ramp down has collapsed, and there is no longer a boat tied there.","These sewers must have been abandoned for ages to have fallen into such poor repair. It's quite probable that you are the first people to even come down here in years. There certainly aren't any maintenance crews.");
		set_flag(2,13,1); }
break;

beginstate 34;
if(get_flag(2,8) == 1) {
	message_dialog("The wheel is stuck.","");
	end(); }
	reset_dialog();
	add_dialog_str(0,"This is a large wooden wheel. A chain is wrapped around it several times and then disappears through a hole in the floor.",0);
	add_dialog_choice(0,"Leave the wheel alone.");
	add_dialog_choice(1,"Try to turn it.");
	choice = run_dialog(0);
	if (choice == 1)
		end();
	play_sound(99);	
	print_str_color("You hear the sounds of grinding gears and the chain",2);
	print_str_color("  scraping over stone.",2);
	swap_floor(23,45,131,4);
	swap_floor(24,45,131,4);
	swap_floor(23,46,58,4);
	swap_floor(24,46,58,4);
	swap_floor(23,47,58,4);
	swap_floor(24,47,58,4);
	swap_floor(21,48,58,4);
	swap_floor(22,48,58,4);
	swap_floor(23,48,58,4);
	swap_floor(24,48,58,4);
	swap_floor(25,48,58,4);
	swap_floor(26,48,58,4);
	swap_floor(21,49,58,4);
	swap_floor(22,49,58,4);
	swap_floor(23,49,58,4);
	swap_floor(24,49,58,4);
	swap_floor(25,49,58,4);
	swap_floor(26,49,58,4);
	swap_floor(21,50,58,4);
	swap_floor(22,50,58,4);
	swap_floor(23,50,58,4);
	swap_floor(24,50,58,4);
	swap_floor(25,50,58,4);
	swap_floor(26,50,58,4);
	set_flag(2,8,1);
break;

beginstate 37;
	if(get_flag(2,15) == 0) {
	message_dialog("This walls of this room drip slime. Acid has destroyed anything that was once here, except several boxes along the southern wall.","");
	set_flag(2,15,1);
}
break;
beginstate 38;
	if(get_flag(2,16) == 0) {
	message_dialog("You hold your nose and dig through the piles of filth in the rats' nest. Beneath a pile of skulls you spot a piece of metal. Closer inspection reveals it to be a barely recognizable key.","");
	change_spec_item(3,1);
	set_flag(2,16,1); }
break;
beginstate 39;
	if(has_special_item(3) == 0)
		message_dialog("The lock on this door is covered in corrosion. If you attempt to pick it you could destroy it for good. You will have to wait until you have the proper key to open it.","");

if(get_flag(2,22) == 0)
	if(has_special_item(3) == 1)
	{	message_dialog("You take out the rusted key you found in the rats nest and try it on the lock. The lock clicks open after some heavy twisting.","");
	set_flag(2,22,1); }
break;
beginstate 40;
	message_dialog("Filth has piled up on the flood gates in front of you. So much, in fact, that it has practically formed a dam. You will have to raise the gates in order to clear this channel.","");
	block_entry(1);
break;
beginstate 41;
	if(has_special_item(2) == 0)
		message_dialog("The door is locked. Nothing you have will open it.","");

if(get_flag(2,23) == 0)
	if(has_special_item(2) == 1)
	{	message_dialog("You pull out the filthy key you found on the dead man. It fits the lock perfectly.","");
		set_flag(2,23,1); }
break;
beginstate 42;
	message_dialog("The rising water has covered up the rocks that were once here, allowing you to safely cros over them. You wouldn't have been able to pass here earlier.","");
break;
beginstate 43;
	if(get_flag(2,17) == 0) {
	message_dialog("This room was once a library and office for whoever was opperating the sewers. The bookshelves were stripped before the sewers were abandoned, but the pedestals across the room still have large volumes chained to them.","");
	set_flag(2,17,1); }
break;
beginstate 44;
	message_dialog("This book is unreadable, most of the pages are soaked and the ink has run so much that it is illegible.","");
break;
beginstate 45;
	reset_dialog();
	add_dialog_str(0,"_The Purpose of the Flood Gates_",0);
	add_dialog_str(1,"Water levels in Mountainwatch's sewers are controlled by a series of flood gates.",0);
	add_dialog_str(2,"The main drainage channel, which flows east, is really just the natural watersource for Lake Tybor. The gates across this channel are only iron bars.",0);
	add_dialog_str(4,"The waterway to the south, however; has massive stone gates, which when closed can completely stop the flow of water. This allows the control of water levels in Lake Tybor.",0);
	add_dialog_str(5,"All gates are controlled from a control panel at the centrally located Main Control Room. However, each of the major gates also posesses a manual emergency switch, located near the respective gates.",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);
	if (choice == 1)
	end();
break;

beginstate 46;
	teleport_party(27,37,1);
break;

beginstate 47;
	if(get_flag(2,14) == 0) {
		message_dialog("You could never have found this secret passage without knowing that it was here. A trapdoor lies at the end of this hidden corridor, it will take you deeper into the sewers.","");
		set_flag(2,14,1); }
break;

beginstate 48;
	if(get_flag(2,18) == 0)
	{	if(get_flag(2,0) == 0) {
			block_entry(1);
			message_dialog("You can't get any further down this passage because of all the debris. If you could clear it, then you could probably walk past here and into Mountainwatch.",""); }
		else {
			message_dialog("This path is now clear. You think you can see a stairway leading up.","");
			set_flag(2,18,1); }
}
break;

beginstate 49;
	move_to_new_town(4,15,60);
		if(get_flag(2,19) == 0) {
			message_dialog("You climb the ladder and emerge in a concealed passage. Hopefully you are now in Mountainwatch.","");
			set_flag(2,19,1); }
break;
	